/*
 * *****************************************************************************
 *  Copyright ( c ) 2019 huibur Inc. All Rights Reserved.
 *
 *  This software is the confidential and proprietary information of Huibur Inc
 *  (*Confidential Information*). You shall not disclose such Confidential Information
 *  and shall use it only in accordance with the terms of the license agreement
 *  you entered into with Huibur or a Huibur authorized
 *  reseller (the "License Agreement*).
 *  ******************************************************************************
 */

package com.huibur.devicecheck.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huibur.devicecheck.model.po.CheckLocationPO;
import com.huibur.devicecheck.model.query.CheckLocationQuery;
import com.huibur.devicecheck.model.vo.CheckLocationVO;
import com.huibur.devicecheck.model.vo.LocationVO;
import com.huibur.devicecheck.model.vo.StatisticVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;

/*******************************************************
* Title: CheckLocationMapper.java
* Description:
* @author baiqingshuo
* @date 2021/10/12
* @version 1.0
*******************************************************/
@Repository
@Mapper
public interface CheckLocationMapper extends BaseMapper<CheckLocationPO> {

    /**
     * 地址列表(查询并分页)
     * @param page
     * @param checkLocationQuery
     * @return
     */
    IPage<CheckLocationVO> selectLocationList(Page<CheckLocationPO> page, CheckLocationQuery checkLocationQuery);

    /**
     * 查询所有的节点
     * @param id
     * @return
     */
    List<LocationVO> selectAllLocation(Long id);

    /**
     * 根据ID来查询子级
     * @param id
     * @return
     */
    List<CheckLocationPO> selectByParentId(Long id);

    /**
     * 获取每个顶级节点的数据
     * @param id
     * @param firstTimestamp
     * @param lastTimestamp
     * @return
     */
    List<StatisticVO> selectStatusNum(@Param("id") Long id, @Param("firstTimestamp")Timestamp firstTimestamp,  @Param("lastTimestamp")Timestamp lastTimestamp);

    Integer findTotalByLocation(String locationId1);
}
